import QtQuick 2.0
import QtQuick.Controls 2.3
import QtQuick.Layouts 1.0

Item {
    id:root
    width: 850
    height: 580
    property real minSize:  Math.min(width/850, height/580)

     

    function readModSingal(handle, sqlName, min, max, point)
    {
//        var t_var = $sqlMcRecorder.qml_getRegulatorVal_bystr_toint16(sqlName)
//        if(t_var >= min && t_var <= max)
//            handle.valueText = String((t_var/Math.pow(10, point)).toFixed(point))
//        else
            handle.valueText = "未定义的点"
    }
    function refurbishA()
    {
        readModSingal(text_aConstantRunValue, "", 0, 10000, 4)
        readModSingal(text_aQLimit, "", 0, 10000, 4)
        readModSingal(text_aUpLimit, "", 1000, 20000, 4)
        readModSingal(text_aCalTopLimit, "", 1000, 32000, 4)
        readModSingal(text_aHeatRelSpeed, "", 1, 2000, 2)
        readModSingal(text_aBreakLimitTime, "", 1, 30000, 2)
        readModSingal(text_aLimitTime, "", 0, 10000, 4)
        readModSingal(text_aIntegralTimeConstant, "A套VF积分时间常数", 0, 10000, 4)
        readModSingal(text_aIntegralMin, "A套VF积分最小值", 1000, 20000, 4)
        readModSingal(text_aIntegralMax, "A套VF积分最大值", 1000, 32000, 4)
        readModSingal(text_aIntegralLimitEnable, "", 1, 2000, 2)
    }


    SwipeView
    {
        id: sv_this
        width:parent.width
        height: parent.height*0.85
        clip: true
        Component.onCompleted:{contentItem.highlightMoveDuration = 0}       //将移动时间设为0

        onCurrentIndexChanged: {
            if(sv_this.currentIndex==0) {button.checked=true;button2.checked=false}
            if(sv_this.currentIndex==1) {button2.checked=true;button.checked=false}
        }

        Item{
            Text {
                x: 220*root.minSize
                y: 20*root.minSize
                text: qsTr("A通道定子电流限制参数")
                anchors.horizontalCenter: parent.horizontalCenter
                font.pixelSize: 40*root.minSize
            }

            Rectangle {
                x: 220*root.minSize
                y: 70*root.minSize
                width: 400*root.minSize
                height: 420*root.minSize
                color: "#6692e8bc"
                radius: 10*root.minSize

                ColumnLayout {
                    x: 30*root.minSize
                    width: 380*root.minSize
                    anchors.bottom: parent.bottom
                    anchors.top: parent.top
                    property real textSize: 23*root.minSize

                    EXC_Normal_DoubleTextSytle3{
                        id: text_aConstantRunValue
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("长期运行值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aQLimit
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("无功限制值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aUpLimit
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("限制启动值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aCalTopLimit
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("计算上限值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aHeatRelSpeed
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("热释放速度:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aBreakLimitTime
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("越限最长时间:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aLimitTime
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("限制时间:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aIntegralTimeConstant
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分时间常数:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aIntegralMin
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分最小值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aIntegralMax
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分最大值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_aIntegralLimitEnable
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分限制使能:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                }
            }

            EXC_Normal_BtnUncheckSecret_highStyle {
                id: btn_ASave
                nameFontpixelSize: 25*root.minSize
                x: 670*root.minSize
                y: 410*root.minSize
                width: 140*root.minSize
                height: 50*root.minSize
                nameText: qsTr("保存参数")
            }

            onFocusChanged:{
                if(!focus) return
                refurbishA()
            }
        }

        Item{
            id: element1
            Text {
                x: 220*root.minSize
                y: 20*root.minSize
                text: qsTr("B通道定子电流限制参数")
                anchors.horizontalCenter: parent.horizontalCenter
                font.pixelSize: 40*root.minSize
            }

            Rectangle {
                x: 220*root.minSize
                y: 70*root.minSize
                width: 400*root.minSize
                height: 420*root.minSize
                color: "#6692e8bc"
                radius: 10*root.minSize

                ColumnLayout {
                    x: 30*root.minSize
                    width: 380*root.minSize
                    anchors.bottom: parent.bottom
                    anchors.top: parent.top
                    property real textSize: 23*root.minSize

                    EXC_Normal_DoubleTextSytle3{
                        id: text_bConstantRunValue
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("长期运行值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bQLimit
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("无功限制值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bUpLimit
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("限制启动值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bCalTopLimit
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("计算上限值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bHeatRelSpeed
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("热释放速度:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bBreakLimitTime
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("越限最长时间:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bLimitTime
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("限制时间:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bIntegralTimeConstant
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分时间常数:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bIntegralMin
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分最小值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bIntegralMax
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分最大值:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                    EXC_Normal_DoubleTextSytle3{
                        id: text_bIntegralLimitEnable
                        width: parent.width*0.8
                        height: 30*root.minSize
                        Layout.preferredWidth:width
                        Layout.preferredHeight: height
                        funcText: qsTr("积分限制使能:")
                        valueText: "???"
                        textSize:parent.textSize
                    }
                }
            }

            EXC_Normal_BtnUncheckSecret_highStyle {
                id: btn_BSave
                nameFontpixelSize: 25*root.minSize
                x: 670*root.minSize
                y: 410*root.minSize
                width: 140*root.minSize
                height: 50*root.minSize
                nameText: qsTr("保存参数")
            }

            onFocusChanged:{
                if(!focus) return
                refurbishB()
            }
        }

    }

    EXC_Normal_BtnSytle {
        id: button
        nameText: qsTr("A通道")
        width: parent.width*0.15
        height: parent.height*0.09
        checked: true
        anchors.left: parent.left
        anchors.leftMargin: parent.width*0.1
        anchors.topMargin: parent.height/32
        anchors.top: sv_this.bottom
        onClicked: {
            if(sv_this.currentIndex==0) checked = true;
            else sv_this.currentIndex = 0
        }
    }

    EXC_Normal_BtnSytle {
        id: button2
        nameText: qsTr("B通道")
        width: parent.width*0.15
        height: parent.height*0.09
        anchors.left: parent.left
        anchors.leftMargin: parent.width*0.43
        anchors.topMargin: parent.height/32
        anchors.top: sv_this.bottom
        onClicked: {
            if(sv_this.currentIndex==1) checked = true;
            else sv_this.currentIndex = 1
        }
    }

    EXC_Normal_BtnUncheckStyle {
        id: button3
        nameText: qsTr("返回")
        nameFontpixelSize: 30*Math.min(root.width/850, root.height/580)
        width: parent.width*0.15
        height: parent.height*0.09
        anchors.left: parent.left
        anchors.leftMargin: parent.width*0.75
        anchors.topMargin: parent.height/32
        anchors.top: sv_this.bottom
        onClicked: {
            sw.currentIndex = 0
        }
    }

}
